﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using sydfdl.TMS.Tool;
using sydfdl.TMS.BLL;
using sydfdl.TMS.Model;

namespace sydfdl.TMS.Areas.SystemData.Controllers
{
    public class ADController : Controller
    {
        // 
        // GET: /SystemData/ad/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Show()
        {
            return View();
        }

        public void GetAD()
        {
            string xml = JsonHelp.GetParaXML(Request.Form.Get("pageIndex"), Request.Form.Get("pageSize"),
                 Request.Form.Get("sortField"), Request.Form.Get("sortOrder"), Request.Form.Get("key"));

            Response.Write(JsonHelp.EntitiesToString(new BLLT_B_Notice().GetList(xml)));
        }

        public void Save()
        {
            string _add = Request.Form.Get("add") ?? @"[]", _edit = Request.Form.Get("edit") ?? @"[]", _del = Request.Form.Get("del") ?? @"[]";

            IEnumerable<T_B_Notice> add = _add == @"[]" ? null : JsonHelp.ConvertJsonToEntity<IEnumerable<T_B_Notice>>(_add);
            IEnumerable<T_B_Notice> edit = _edit == @"[]" ? null : JsonHelp.ConvertJsonToEntity<IEnumerable<T_B_Notice>>(_edit);
            IEnumerable<T_B_Notice> del = _del == @"[]" ? null : JsonHelp.ConvertJsonToEntity<IEnumerable<T_B_Notice>>(_del);

            Response.Write(new BLLT_B_Notice().Save(add, edit, del));
        }

    }
}
